<?php

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

/**
 * 定时任务  5分钟一次
 */

use Biz\model\eventlog\TransactionLog  as mTransactionLog;
use Doraemon\amqp\Queue;


$where = [
    'status'=>mTransactionLog::STATUS_NORMAL,
    'retries[>]'=>1,
    'ORDER'=>['last_uptime'=>'DESC']
];


$logList = mTransactionLog::select('*',$where);


if(empty($logList)){
    return false;
}


$msgContent = ['异步消费事件完整性报警消息，报警时间:'.date('Y-m-d H:i:s')];

foreach ($logList as $info){
    $msgContent[] = vsprintf("bizid=%s,slot=%s,尝试次数=%s,最后更新时间=%s",[
        $info['bizid'],
        $info['slot'],
        $info['retries'],
        $info['last_uptime']
    ]);
}




//事件push任务处理异常
Queue::insertQueue("queue/Wechatnotice/toTag", [
    "totag"=>\Biz\pockets\constInterface\BizWechatTagConfig::TAG_BIZ_RD_SYSTEM,
    "content" =>implode("\r\n",$msgContent)
], Queue::QUEUE_BIZ);